const initialState = {
    totalNum: 0
}

export default (state = initialState, action) => {
    switch (action.type) {
        case "SYNC_CART_GOODS":
            // console.log(action);
            let { goodsList } = action.payload
            let totalNum = 0;
            for (let key in goodsList) {
                totalNum += goodsList[key].amount
            }
            // console.log({ ...state, totalNum, ...action.payload });
            return { ...state, totalNum, ...action.payload }
        case "BUY_NOW":
            return {...state,...action.payload}
        default:
            return state
    }
}